package com.woniu.market_stall.web;

import com.github.pagehelper.PageInfo;
import com.woniu.market_stall.result.ResultResponse;
import com.woniu.market_stall.service.StallDetailService;
import com.woniu.market_stall.vo.StallDetailVo;
import com.woniu.market_stall.vo.StallVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("stallDetail")
public class StallDetailController {
    @Autowired
    StallDetailService stallDetailService;


    @GetMapping("/list")
    @ApiOperation(value = "本接口是查询按条件分页查询摊位详情数据的")
    public ResultResponse<PageInfo<StallDetailVo>> list(
            @ApiParam(value = "当前页的参数") @RequestParam(value = "now",defaultValue = "1") Integer now,
            @ApiParam(value = "页面大小的参数") @RequestParam(value = "size",defaultValue = "3")Integer size,
            @ApiParam(value = "摊位id") @RequestParam(value = "stallId") int stallId ,
            @ApiParam(value = "按条件搜索的摊位详情状态") @RequestParam(value = "status",defaultValue = "") String status,
            @ApiParam(value = "按条件搜索的用户的id") @RequestParam(value = "username",defaultValue = "") String username){
        ResultResponse<PageInfo<StallDetailVo>> result = null;
        try {
            PageInfo<StallDetailVo> pageInfo = stallDetailService.queryStallDetailByPage(now, size ,username , status , stallId );
            result = new ResultResponse<>(200,"查询摊位详情成功!",pageInfo);
        }catch (RuntimeException e){
            e.printStackTrace();
            result = new ResultResponse<>(201,"查询摊位详情失败!");
        }
        return result ;
    }


}
